﻿using Prism.Commands;
using Prism.Mvvm;
using RoboAssembleX.Application.Robot;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RoboAssembleX.ViewModels
{
    public class ViewRoboControlViewModel: BindableBase
    {

        private readonly RoboService roboService;

        public DelegateCommand<string> ButtonCommand { get; private set; }
        public RoboModel RoboModel { get; }

        public ViewRoboControlViewModel(RoboService roboService, RoboModel roboModel)
        {
            ButtonCommand = new DelegateCommand<string>(ButtonMethod);
            this.roboService = roboService;
            RoboModel = roboModel;
            ////启动加载
            Task.Run(async () => {

                await Task.Delay(1000);
                roboService.SwitchReadData();
            });
        }

        private void ButtonMethod(string menuName)
        {
            switch (menuName)
            {
                case "SwitchReadData":
                    roboService.SwitchReadData();
                    break;
                case "RunAction1":
                    roboService.Action1Async();
                    break;
                case "RunAction2":
                    roboService.Action2Async();
                    break;
                case "RunAction3":
                    roboService.Action3Async();
                    break;
                case "RunAction4":
                    roboService.Action4Async();
                    break;
                case "RunAction5":
                    roboService.Action5Async();
                    break;
                case "RunAction6":
                    roboService.Action6Async();
                    break;
                case "RunAction7":
                    roboService.Action7Async();
                    break;
                case "RunAction8":
                    roboService.Action8Async();
                    break;
                case "RunAction9":
                    roboService.Action9Async();
                    break;
                case "RunAction10":
                    roboService.Action10Async();
                    break;
                case "RunAction11":
                    roboService.Action11Async();
                    break;
                case "RunAction12":
                    roboService.Action12Async();
                    break;
                case "SwitchPowerOn":
                    roboService.SwitchPowerOn();
                    break;
                case "SwitchRobotEnable":
                    roboService.SwitchRoboEnable();
                    break;
                case "CollisionRecover":
                    roboService.CollisionRecover();
                    break;
                case "SwitchProgramRun":
                    roboService.SwitchProgramRun();
                    break;
            }
        }
    }
}
